package com.violet.myorm.core.condition;

import java.util.List;

public interface Where<E, R extends Where<E, ?>>
{
    List<String> getWhere();
    List<Object> getWhereParams();

    default String getFieldName(SerializableFunction<?, ?> function) {
        return function.getName().replaceAll("[A-Z]", "_$0").toLowerCase();
    }

    default R join(String fieldName, String joinCondition, Object... values) {
        getWhere().add(fieldName + joinCondition);
        for (Object value : values) getWhereParams().add(value);
        return (R) this;
    }

    <T> R gt(String fieldName, T value);
    <T> R gte(String fieldName, T value);

    <T> R lt(String fieldName, T value);
    <T> R lte(String fieldName, T value);

    <T> R between(String fieldName, T value1, T value2);

    <T> R eq(String fieldName, T value);
    <T> R ne(String fieldName, T value);

    R like(String fieldName, String value);

    <T> R in(String fieldName, T... values);
    <T> R notIn(String fieldName, T... values);

    <T> R notNull(String fieldName);
    <T> R isNull(String fieldName);

    R and();
    R or();
    R not();
}
